package com.cy.pj.sys.service.impl;

import com.cy.pj.sys.dao.SysMenuDao;
import com.cy.pj.sys.pojo.SysMenu;
import com.cy.pj.sys.service.SysMenuService;
import com.cy.pj.common.pojo.Node;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
/**菜单业务管理*/
@Service
public class SysMenuServiceImpl implements SysMenuService {
    @Autowired
    private SysMenuDao sysMenuDao;
    @Cacheable("sysMenu")
    @Override
    public List<SysMenu> findMenus() {
        return sysMenuDao.selectMenus();
    }
    @CacheEvict(value = "sysMenu",allEntries = true)
    @Override
    public int saveMenu(SysMenu menu) {
        return sysMenuDao.insertMenu(menu);
    }
    @CacheEvict(value = "sysMenu",allEntries = true)
    @Override
    public int updateMenu(SysMenu menu) {
        return sysMenuDao.updateMenu(menu);
    }

    @Override
    public List<Node> findMenuTreeNodes() {
        return sysMenuDao.selectMenuTreeNodes();
    }
}
